//
//  BaseTableViewController.m
//  CarUser
//
//  Created by 王森林 on 2018/11/30.
//  Copyright © 2018年 王森林. All rights reserved.
//

#import "BaseTableViewController.h"

@interface BaseTableViewController ()
@property (assign, nonatomic) UITableViewStyle tableViewStyle;
@end

@implementation BaseTableViewController



- (instancetype)initWithTableViewStyle:(UITableViewStyle)style {
    if (self = [super init]) {
        self.tableViewStyle = style;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
     [self createBaseUI];
    // Do any additional setup after loading the view.
}

#pragma mark - UI相关
- (void) createBaseUI {
    self.mainTableView = ({
        UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:self.tableViewStyle];
        tableView.frame  = CGRectMake(0, 0, BOUNDWIDTH, BOUNDHEIGHT-NAV_HEIGHT-TABBAR_HEIGHT);
        tableView.dataSource = self;
        tableView.delegate = self;
        tableView.backgroundColor = Common_BackgroundColor;
        tableView.separatorColor = Common_SepeColor;
        tableView.separatorStyle  = UITableViewCellEditingStyleNone;
        tableView.showsVerticalScrollIndicator = NO;
        if (self.tableViewStyle == UITableViewStylePlain) {
            tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.frame), CGFLOAT_MIN)];
            tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.frame), CGFLOAT_MIN)];
        }
        tableView.clipsToBounds = YES;
        //1.调整(iOS7以上)表格分隔线边距
        if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
            tableView.separatorInset = UIEdgeInsetsMake(-0.5, kMarginLeft, 0, kMarginRight);
        }
        //2.调整(iOS8以上)view边距(或者在cell中设置preservesSuperviewLayoutMargins,二者等效)
        if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
            tableView.layoutMargins = UIEdgeInsetsMake(-0.5, kMarginLeft, -0.5, kMarginRight);
        }
        
        [self.view addSubview:tableView];
        tableView;
    });
    
//    [self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.mas_equalTo(0);
//        //        make.top.left.right.mas_equalTo(0);
//        //        make.bottom.mas_equalTo(-);
//    }];
    
}
#pragma mark - 事件响应处理
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
    }
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
}

#pragma mark - 其他私有方法

#pragma mark - 网络请求

#pragma mark - 代理方法

#pragma mark - setter & getter

#pragma mark - 内存管理相关


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
